
# -*- coding: UTF-8 -*-

##为测试注册功能，我们需要一千个手机号和密码。请设计一个函数产生指定数量（1~100000000）的手机号和密码，该函数返回一个手机号和密码的字典列表。
# 要求，手机号和密码都不能重复，且密码必须包含大小写与下划线，可包含数字，长度不小于8，不大于16。

import random,string

def Createphone():
    list2=['133','149','153','173','177','180','181','189','199','130','131','132','145','155','156','166',
           '171','175','176','185','186','166','135','136','137','138','139','147',
           '150','151','152','157','158','159','172','178','182','183','184','187','188','198','134']
    phoneafter=''.join(random.sample('0123456789',8))
    return '{}{}'.format(random.choice(list2),phoneafter)


def CreatePwd():
    pwd=random.sample(string.ascii_letters,5)+random.sample(string.digits,6)
    pwd.append('_')
    random.shuffle(pwd)  #对已有元素排序
    return ''.join(pwd)

def dictP(n):
    dictlogin={}
    while True:
        if len(dictlogin)==n:
            break
        phone = Createphone()
        if phone in dictlogin:
            continue
        dictlogin.update({phone:CreatePwd()})
    return dictlogin

if __name__ == '__main__':
    print(dictP(10))